package Nova.ch4.correctExtself.correct.correct;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.concurrent.EventExecutorGroup;

import java.nio.charset.Charset;

public class StringSelfEncoder  extends MessageToByteEncoder<Object> {
    final static Charset UTF_8 = Charset.forName("utf-8");
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Object o, ByteBuf byteBuf) throws Exception {
        String curr=(String)o;
        ByteBuf resp = Unpooled.copiedBuffer(curr,UTF_8);
        byteBuf.writeBytes(resp);
    }
}
